package com.hangzhou.xyj.net.request;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.hangzhou.xyj.net.request.base.BaseRequest;
import com.hangzhou.xyj.utils.constants.API;

/**
 * Created by yaohuix on 2016/2/19  15:25
 * <p/>
 * 说明：添加关注 请求
 */
public class AddFollowReq extends BaseRequest {
    public static final int TYPE_USER = 1;//用户
    public static final int TYPE_GROUP = 2;//圈子
    public static final int TYPE_DYNAMIC = 3;//动态

    /**
     * @param type     关注的类型：1，用户；2，圈子；3，动态；
     * @param followId 关注的对象的ID
     * @param userId   关注人的ID
     * @return
     * @author yaohuix
     * @date 2016/3/21 16:34
     */
    public AddFollowReq(int type, int followId, int userId) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("type", type);
        jsonObject.addProperty("followId", followId);
        jsonObject.addProperty("userId", userId);
        String data = new Gson().toJson(jsonObject);
        setData(data);
    }

    private long convertValue(String value) {
        try {
            return Long.valueOf(value);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return -1;
    }

    public void setData(String data) {
        add("data", data);
    }

    @Override
    public String getUrl() {
        return API.MY_ADD_FOLLOW;
    }
}
